<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<title>内部管理系统</title>
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">

<link rel="stylesheet" type="text/css"
	href="../../lib/bootstrap/css/bootstrap.css">
<link rel="stylesheet" type="text/css"
	href="../../stylesheets/theme.css">
<link rel="stylesheet"
	href="../../lib/font-awesome/css/font-awesome.css">

<script src="../../lib/jquery.min.js" type="text/javascript"></script>
<script src="../../lib/bootstrap/js/bootstrap.js"></script>
<script src="../../lib/jquery.validate.min.js"></script>
<script src="../../lib/jquery.cookie.js"></script>
<script src="../../lib/jquery.messager.js"></script>
<script src="../../js/init.js"></script>


<!-- <script src="../../lib/jquery.min.js" type="text/javascript"></script>
<script src="../../lib/bootstrap/js/bootstrap.js"></script>
<script src="../../lib/jquery.validate.min.js"></script>
<script src="../../lib/jquery.cookie.js"></script>
<script src="../../lib/jquery.messager.js"></script>
<script src="../../lib/messages_cn.js" type="text/javascript"></script>
<script src="../../js/init.js"></script>
<link rel="stylesheet" href="//apps.bdimg.com/libs/jqueryui/1.10.4/css/jquery-ui.min.css">
<script src="//apps.bdimg.com/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//apps.bdimg.com/libs/jqueryui/1.10.4/jquery-ui.min.js"></script> -->
<style type="text/css">
#container {
	height: 300px;
	width: 400px;
}

.fl {
	float: left
}

select {
	width: 130px;
}

.title {
	font-size: 18px;
	font-weight: bold;
}
</style>
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
      <script src="lib/html5.js"></script>
    <![endif]-->
</head>

<!--[if lt IE 7 ]> <body class="ie ie6"> <![endif]-->
<!--[if IE 7 ]> <body class="ie ie7 "> <![endif]-->
<!--[if IE 8 ]> <body class="ie ie8 "> <![endif]-->
<!--[if IE 9 ]> <body class="ie ie9 "> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!-->
<body class="">
	<!--<![endif]-->

	<div class="navbar"></div>
	<div class="common"></div>

	<div class="sidebar-nav"></div>

	<div class="content">
		<div class="well">
			<ul class="nav nav-tabs">
				<li class="active"><a href="#userlist" data-toggle="tab">企业</a></li>
			</ul>
			<div id="myTabContent" class="tab-content">
				<div class="container-fluid">
					<div class="span8">
						<form class="form-horizontal" id="user_form">
							<div class="control-group title">实习岗位详情</div>
							<input type="hidden" id="companyId">
							<input type="hidden" id="postId">
							<input type="hidden" id="postFlag">
							<input type="hidden" id="dicInternshipFieldId_hidden">
							<input type="hidden" id="minEducationId_hidden">
							<input type="hidden" id="provinceId_hidden">
							<input type="hidden" id="cityId_hidden">
							<input type="hidden" id="districtId_hidden">
							<table class="table">
								<tr>
									<td><label class="control-label">岗位名称：</label></td>
									<td>
										<input type="text"  id="internshipName" name="internshipName" placeholder="岗位名称">
									</td>
									<td><label class="control-label">领域：</label></td>
									<td>
										<select name="dicInternshipFieldId" id="dicInternshipFieldId"></select>
									</td>
								</tr>
								<tr>
									<td><label class="control-label">工资(K)：</label></td>
									<td>
										<input type="text"  class="input-mini" id="minSalary" name="minSalary" placeholder="最低工资">
										－
										<input type="text"  class="input-mini" id="maxSalary" name="maxSalary" placeholder="最高工资">
									</td>
									<td><label class="control-label">最低学历：</label></td>
									<td>
										<select name="minEducationId" id="minEducationId"></select>
									</td>
								</tr>
								<tr>
									<td><label class="control-label">地区：</label></td>
									<td>
										<select name="provinceId" id="provinceId" onchange="loadCity()"></select>
										<select name="cityId" id="cityId" onchange="loadDistrict()"></select>
										<select name="districtId" id="districtId"></select>
									</td>
									<td><label class="control-label">地址：</label></td>
									<td>
										<input type="text"  id="location" name="location" placeholder="地址">
									</td>
								</tr>
								<tr>
									<td><label class="control-label">招聘人数：</label></td>
									<td>
										<input type="text"  id="recruitingNumbers" name="recruitingNumbers" placeholder="招聘人数">
									</td>
									<td><label class="control-label">简介：</label></td>
									<td>
										<input type="text"  id="description" name="description" placeholder="简介">
									</td>
								</tr>
								<tr>
									<td><label class="control-label">岗位要求：</label></td>
									<td>
										<input type="text"  id="requirement" name="requirement" placeholder="岗位要求">
									</td>
									<td><label class="control-label">电话：</label></td>
									<td>
										<input type="text"  id="tel" name="tel" placeholder="电话">
									</td>
								</tr>
							</table>

						</form>
					</div>
				</div>
				<div class="form-actions">
					<button id="btn-back" type="button" class="btn ">返回</button>
					<button id="btn-save" type="button" class="btn ">保存</button>
				</div>
			</div>
		</div>
	</div>


	<script type="text/javascript">
	
		//初始化导航栏
		$(function() {
			initAdminNavBar();
			initCommon();
			initSideBar('user-management', 'company-list');
			reloadtable();

		});
		
		//初始化页面信息
		function onload(){
			var postId = getparastr('postId');
			var postFlag = getparastr('postFlag');
			var companyId = getparastr('companyId');
			$("#companyId").val(companyId);
			
			$.ajax({
				contentType : "application/json",
				url : api_base_url1
						+ "open/dic/selectInternshipField4Page.json",
				dataType : "json",
				success : function(data) {
					if (data.code == "200") {
						var options = "<option value='0'>请选择</option>";

						for (var int = 0; int < data.responseData.length; int++) {
							options += "<option value='" + data.responseData[int].dicFieldId
									+ "'>" + data.responseData[int].dicFieldName
									+ "</option> ";
						}
						$('#dicInternshipFieldId').html(options);
						var dicInternshipFieldId_hidden = $('#dicInternshipFieldId_hidden').val();
						$("#dicInternshipFieldId").val(dicInternshipFieldId_hidden);
					}
				}
			});
			$.ajax({
				contentType : "application/json",
				url : api_base_url1
						+ "open/dic/selectEducation.json",
				dataType : "json",
				success : function(data) {
					if (data.code == "200") {
						var options = "<option value='0'>请选择</option>";

						for (var int = 0; int < data.responseData.length; int++) {
							options += "<option value='" + data.responseData[int].dicEducationId
							+ "'>" + data.responseData[int].dicEducationName
									+ "</option> ";
						}
						$('#minEducationId').html(options);
						var minEducationId_hidden = $('#minEducationId_hidden').val();
						$("#minEducationId").val(minEducationId_hidden);
					}
				}
			});
			$.ajax({
				contentType : "application/json",
				url : api_base_url1
						+ "open/dic/selectDistrictList.json?level=1",
				dataType : "json",
				success : function(data) {
					if (data.code == "200") {
						var options = "<option value='0'>请选择</option>";

						for (var int = 0; int < data.responseData.length; int++) {
							options += "<option value='" + data.responseData[int].dicDistrictId
									+ "'>" + data.responseData[int].dicDistrict
									+ "</option> ";
						}
						$('#provinceId').html(options);
						var provinceId_hidden = $('#provinceId_hidden').val();
						$("#provinceId").val(provinceId_hidden); 
					}
				}
			});
			var provinceId_hidden = $('#provinceId_hidden').val();
			if(provinceId_hidden != null && provinceId_hidden != ""){
				loadCity(provinceId_hidden);
			}
			var cityId_hidden = $('#cityId_hidden').val();
			if(cityId_hidden != null && cityId_hidden != ""){
				loadDistrict(cityId_hidden);
			}
		}
		
		function loadCity(provinceId_hidden){
			var provinceId = $('#provinceId').val();
			if(provinceId == null || provinceId == ""){
				provinceId = provinceId_hidden;
			}
		     $("#cityId").empty();
		     $("#districtId").empty();
		     $.ajax({
					contentType : "application/json",
					url : api_base_url1
							+ "open/dic/selectDistrictList.json?level=2&parentId=" + provinceId,
					dataType : "json",
					success : function(data) {
						if (data.code == "200") {
							var options = "<option value='0'>请选择</option>";

							for (var int = 0; int < data.responseData.length; int++) {
								options += "<option value='" + data.responseData[int].dicDistrictId
								+ "'>" + data.responseData[int].dicDistrict
										+ "</option> ";
							}
							$('#cityId').html(options);
							var cityId_hidden = $('#cityId_hidden').val();
							$("#cityId").val(cityId_hidden);
						}
					}
				});
		}
		
		function loadDistrict(cityId_hidden){
			var cityId = $('#cityId').val();
			if(cityId == null || cityId == ""){
				cityId = cityId_hidden;
			}
		     $("#districtId").empty();
		     $.ajax({
					contentType : "application/json",
					url : api_base_url1
							+ "open/dic/selectDistrictList.json?level=3&parentId=" + cityId,
					dataType : "json",
					success : function(data) {
						if (data.code == "200") {
							var options = "<option value='0'>请选择</option>";

							for (var int = 0; int < data.responseData.length; int++) {
								options += "<option value='" + data.responseData[int].dicDistrictId
								+ "'>" + data.responseData[int].dicDistrict
										+ "</option> ";
							}
							$('#districtId').html(options);  
							var districtId_hidden = $('#districtId_hidden').val();
							$("#districtId").val(districtId_hidden);
						}
					}
				});
		}
		
		//初始化用户详细信息
		function reloadtable() {
			var companyId = getparastr('companyId');
			var postId = getparastr('postId');
			var postFlag = getparastr('postFlag');
			if (postId != null && postId != "" && postFlag != null && postFlag != "") {//更新的情况下,给页面赋初始值
				$.ajax({
					contentType : "application/json",
					url : api_base_url
							+ "selectPostDetail.json?postId="
							+ postId + "&postFlag=" + postFlag,
					dataType : "json",
					success : function(data) {
						if (data.code == "200") {
							var postId = data.responseData.postId;
							var postFlag = data.responseData.postFlag;
							var companyId = data.responseData.companyId;
							var internshipName = data.responseData.internshipName;
							var dicInternshipFieldId = data.responseData.dicInternshipFieldId;
							var dicInternshipFieldName = data.responseData.dicInternshipFieldName;
							var minSalary = data.responseData.minSalary;
							var maxSalary = data.responseData.maxSalary;
							var minEducationId = data.responseData.minEducationId;
							var minEducationName = data.responseData.minEducationName;
							var recruitingNumbers = data.responseData.recruitingNumbers;
							var provinceId = data.responseData.provinceId;
							var cityId = data.responseData.cityId;
							var districtId = data.responseData.districtId;
							var district = data.responseData.district;
							var location = data.responseData.location;
							var description = data.responseData.description;
							var requirement = data.responseData.requirement;
							var createDate = data.responseData.createDate;
							var tel = data.responseData.tel;
							$("#postId").val(postId);
							$("#postFlag").val(postFlag);
							$("#companyId").val(companyId);
							$("#internshipName").val(internshipName);
							$("#minSalary").val(minSalary);
							$("#maxSalary").val(maxSalary);
							$("#dicInternshipFieldId_hidden").val(dicInternshipFieldId);
							$("#minEducationId_hidden").val(minEducationId);
							$("#recruitingNumbers").val(recruitingNumbers);
							$("#provinceId").html(provinceId);
							$("#provinceId_hidden").val(provinceId);
							$("#cityId").html(cityId);
							$("#cityId_hidden").val(cityId);
							$("#districtId_hidden").val(districtId);
							$("#district").val(district);
							$("#location").val(location);
							$("#description").val(description);
							$("#requirement").val(requirement);
							$("#tel").val(tel);
							onload();
							
						}
						$.messager.anim('fade', 1000);
					    $.messager.show('操作提示',data.msg, 5000);
					}
				});
			}  else{
				onload();
			}

		}


		//返回
		$('#btn-back').on('click', function() {
			history.back()
		});
		
		//保存
		$('#btn-save').on('click', function() {
			var postId = $('#postId').val();
			var postFlag = $('#postFlag').val();
			var companyId = $('#companyId').val();
			
			var internshipName = $('#internshipName').val();
			var dicInternshipFieldId = $('#dicInternshipFieldId').val();
			var minSalary = $('#minSalary').val();
			var maxSalary = $('#maxSalary').val();
			var minEducationId = $('#minEducationId').val();
			var recruitingNumbers = $('#recruitingNumbers').val();
			var districtId = $('#districtId').val();
			var location = $('#location').val();
			var description = $('#description').val();
			var requirement = $('#requirement').val();
			var tel = $('#tel').val();
			
			$.ajax({
				contentType : "application/json",
				url : api_base_url
						+ "saveInternshipDetail.json?internshipId=" + postId
						+ "&postFlag=" + postFlag
						+ "&companyId=" + companyId
						+ "&internshipName=" + internshipName
						+ "&dicInternshipFieldId=" + dicInternshipFieldId
						+ "&minSalary=" + minSalary
						+ "&maxSalary=" + maxSalary
						+ "&minEducationId=" + minEducationId
						+ "&recruitingNumbers=" + recruitingNumbers
						+ "&districtId=" + districtId
						+ "&location=" + location
						+ "&description=" + description
						+ "&requirement=" + requirement
						+ "&tel=" + tel,
				dataType : "json",
				success : function(data) {
					
					$.messager.anim('fade', 1000);
				    $.messager.show('操作提示',data.msg, 5000);
				}
			});
		});



	</script>

</body>
</html>


